<div class="span3 hide" id="user-edit-block">
	<button class="btn btn-mini" id="switch-user-add-btn">
		<i class="icon-backward"></i> <?php echo t('buttons', 'Back to Add'); ?>
	</button>
	<h4 class="title"><?php echo t('page', 'Edit User'); ?></h4>
	<div class="squiggly-border"></div>
	<div class="row-fluid">	
		<div class="span12 edit_user_form_info hide" id="edit_user_success_info">
			<div class="alert alter-block alert-success">
<!--				<button type="button" class="close" data-dismiss="alert">&times;</button>-->
				<h4>Success</h4>
				<div class="content">User has been saved!</div>
			</div>
		</div>
	</div>
	
	<div class="row-fluid">	
		<div class="span12 edit_user_form_info hide" id="edit_user_error_info">
			<div class="alert alter-block alert-error">
<!--				<button type="button" class="close" data-dismiss="alert">&times;</button>-->
				<h4>Error</h4>
				<div class="content"></div>
			</div>
		</div>
	</div>
	
	<?php $form = $this->beginWidget('CActiveForm', array(
		'id' => 'user-edit-form',
		'enableClientValidation' => true,
		'clientOptions' => array(
			'validateOnSubmit' => true,
		),
	)); ?>
	
		<?php echo $form->hiddenField($userEditForm, 'id_user', array('class' => 'fields')); ?>
		
		<div class="row-fluid">
			<?php echo $form->textField($userEditForm, 'firstname', array('placeholder' => $userEditForm->getFieldLabel('firstname'), 'class' => 'fields')); ?>
		</div>
	
		<div class="row-fluid">
			<?php echo $form->textField($userEditForm, 'lastname', array('placeholder' => $userEditForm->getFieldLabel('lastname'), 'class' => 'fields')); ?>
		</div>
		
		<div class="row-fluid">
			<?php echo $form->textField($userEditForm, 'email', array('placeholder' => $userEditForm->getFieldLabel('email'), 'class' => 'fields')); ?>
		</div>
		
		<div class="row-fluid">
			<?php echo $form->textField($userEditForm, 'username', array('placeholder' => $userEditForm->getFieldLabel('username'), 'class' => 'fields')); ?>
		</div>
		
		<div class="row-fluid">
			<?php echo $form->passwordField($userEditForm, 'password', array('placeholder' => $userEditForm->getFieldLabel('password') . '(leave blank if do not change it)', 'class' => 'fields')); ?>
		</div>
		
		<div class="row-fluid">
			<?php echo $form->passwordField($userEditForm, 'password_confirm', array('placeholder' => $userEditForm->getFieldLabel('password_confirm') . '(leave blank if do not change it)', 'class' => 'fields')); ?>
		</div>
		
		<div class="row-fluid">
			<?php echo $form->dropDownList($userEditForm, 'id_user_role', $userEditForm->listExistedRoles(), array('placeholder' => $userEditForm->getFieldLabel('id_user_role'), 'class' => 'fields')); ?>
		</div>
		
		<div class="row-fluid">
			<?php echo $form->dropDownList($userEditForm, 'status', $userEditForm->statusDatasource(), array('placeholder' => $userEditForm->getFieldLabel('status'), 'class' => 'fields')); ?>
		</div>
	
		<div class="row-fluid buttons">
			<?php echo CHtml::ajaxSubmitButton(
				t('buttons', 'Edit User'), 
				app()->createUrl('user/edit'),
				array(
					'type' => 'post',
					'beforeSend' => 'function(){
						$("#edit_user_submit").button("loading");
					}',
					'success' => 'function(ret){
						$(".edit_user_form_info").hide();
						$("#edit_user_submit").button("reset");
						if(ret["result"]){
							$("#edit_user_success_info").blink({
								"beforeCall": function(){
									$(".user_edit-line .username").text($("#UserEditForm_username").val());
									$(".user_edit-line .fullname").text($("#UserEditForm_firstname").val()+" "+$("#UserEditForm_lastname").val());
									$(".user_edit-line .email").text($("#UserEditForm_email").val());
									$(".user_edit-line .status").text($("#UserEditForm_status option:selected").text().replace("Status: ", ""));
									$(".user_edit-line .role").text($("#UserEditForm_id_user_role option:selected").text().replace("Role: ", ""));
								}
							});
						}else{
							$("#edit_user_error_info").blink({
								"beforeCall": function(){
									$("#edit_user_error_info .content").html("");
									$.each(ret["errors"], function(attrName, error){
										$(error).each(function(k, e){
											var p = $("<p />").addClass("text-error").append(attrName+": "+e);
											$("#edit_user_error_info .content").append(p);
										});
									});
								}
							});
						}
					}',
					'dataType' => 'json'
				),
				array(
					'id' => 'edit_user_submit',
					'type' => 'button', 
					'class' => 'btn btn-small btn-primary',
					'data-loading-text' => t('buttons', 'Saving...')
				)
			); ?>
		</div>
	
	<?php $this->endWidget(); ?>
</div>